package com.liesp.hrm.service.impl;

import java.util.Hashtable;
import java.util.List;

import com.liesp.hrm.bean.Product;
import com.liesp.hrm.dao.ICartProductDAO;
import com.liesp.hrm.dao.impl.CartProductDAOImpl;
import com.liesp.hrm.exception.DAOException;
import com.liesp.hrm.exception.ServiceException;
import com.liesp.hrm.service.ICartProductService;

public class CartProductServiceImpl implements ICartProductService {
	
	private ICartProductDAO cartProductDAO;

	public CartProductServiceImpl() {
		cartProductDAO = new CartProductDAOImpl();
	}
	
	public ICartProductDAO getiCartProductDAO() {
		return cartProductDAO;
	}

	public void setiCartProductDAO(ICartProductDAO iCartProductDAO) {
		this.cartProductDAO = iCartProductDAO;
	}

	public void addToCart(List<Product> vec, String id) throws ServiceException {
		try {
			cartProductDAO.addToCart(vec, id);
		} catch (DAOException e) {
			throw new ServiceException(e.getMessage(),e);
		}
	}

	public void clearCart() {
		cartProductDAO.clearCart();
	}

	public void deleteFromCart(String id) {
		cartProductDAO.deleteFromCart(id);
	}

	public Hashtable getCartContent() {
		return cartProductDAO.getCartContent();
	}

	public boolean isEmpty() {
		return cartProductDAO.isEmpty();
	}

	public void productNotExit(List<Product> vec, String id) throws ServiceException {
		try {
			cartProductDAO.productNotExit(vec, id);
		} catch (DAOException e) {
			throw new ServiceException(e.getMessage(),e);
		}
	}

}
